﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Brio.Framework
{
    public abstract class MusicalOperator
    {
        public MusicalOperator(string name, double percentage, OperatorType type)
        {
            this.name = name;
            this.percentage = percentage;
            shouldApply = false;
        }

        private bool shouldApply;
        private double percentage;
        private string name;
        private OperatorType type;

        public bool ShouldApply
        {
            get { return shouldApply; }
        }

        public string Name
        {
            get { return name; }
        }

        public OperatorType Type
        {
            get { return type; }
        }

        /// <summary>
        /// Decide whether to apply the
        /// </summary>
        public void PreExecute()
        {
            // TODO: Change for consistancy
            double randomNumber = Constants.Random.NextDouble() * 100.0;
            if (name.Equals("Crossover"))
            {
                this.type = OperatorType.Diploid;
            }
            shouldApply = randomNumber < percentage;
        }

        // For Haploid Operators
        // TODO:
        // 1) hardcoded
        // 2) delegates
        // 3) LUA
        public abstract void Apply(MotifChromosome chromo);

        // For Haploid Operators
        // TODO:
        // 1) hardcoded
        // 2) delegates
        // 3) LUA
        public abstract void Apply(MotifChromosome chromo, TechniqueCollection techniqueCollection);

        // For Haploid Operators
        // TODO:
        // 1) hardcoded
        // 2) delegates
        // 3) LUA
        public abstract void Apply(MotifChromosome chromo, IntervalRelationshipTable intervalRelationships);

        // For Diploid Operators
        // TODO:
        // 1) hardcoded
        // 2) delegates
        // 3) LUA
        public abstract void Apply(MotifChromosome doner, MotifChromosome reciever);
        


    }

    public enum OperatorType
    {
        Haploid, Diploid
    }
}
